package form;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.*;
import java.util.ArrayList;

import javax.swing.*;

public class Form extends JFrame implements ItemListener {
	private JLabel DieAntwort;
	private JLabel DeOpening;
	private JCheckBox AC;
	private JCheckBox ABS;
	private HoogMiddenLaag antwoordMachine;
	private int[] yn_binary;
	JPanel holdAll = new JPanel();
		
	public Form(ArrayList<String> f, HoogMiddenLaag a) {
		antwoordMachine = a;
		yn_binary = new int[f.size()];
		for(int i =0; i< yn_binary.length;i++){
			yn_binary[i] = 0;
		}
		create();
		
	}
	
	public void create() {
		AC = new JCheckBox("Airco");
		ABS = new JCheckBox("REM ding");
		DieAntwort = new JLabel("Hier komt het advies!");
		DeOpening = new JLabel("Selecteer wat je ooto heeft.");
		
	    holdAll.setLayout(new FlowLayout());
	    holdAll.add(DeOpening);
	    holdAll.add(ABS);
	    holdAll.add(AC);
	    holdAll.add(DieAntwort);
	 
	    getContentPane().add(holdAll, BorderLayout.CENTER);
		AC.addItemListener(this);
		ABS.addItemListener(this);

	 
	    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		
		
	}
	
	public void itemStateChanged(ItemEvent e) {
		Object source = e.getItemSelectable();
		if (source == AC)
			if (e.getStateChange() == ItemEvent.SELECTED)
				yn_binary[0] = 1;
			else
				yn_binary[0] = 0;
		if (source == ABS)
			if (e.getStateChange() == ItemEvent.SELECTED)
				yn_binary[1] = 1;
			else
				yn_binary[1] = 0;
		
		DieAntwort.setText("De categorie: \n" + antwoordMachine.getAntwort(yn_binary));
		
	}
	

}
